"""
管理员接口层
"""
from db import db_handler
from lib import common
#产生一个日志对象
logginger = common.get_log("admin")
#修改用户额度
def change_blance(user_name,money):
    user_dic = db_handler.select(user_name)
    if user_dic:     
        user_dic["balance"] = int(money)
        db_handler.save(user_dic)
        msg = f"{user_name}的余额已经被修改为{int(money)}"
        logginger.info(msg)
        return True,msg
    return False,f"所要修改的{user_name}用户不存在"

#锁定用户
def lock(user_name):
    user_dic = db_handler.select(user_name)
    if user_dic:     
        user_dic["locked"] = True
        db_handler.save(user_dic)
        msg = f"{user_name}已经被冻结"
        logginger.info(msg)
        return True,msg
    return False,f"所要修改的{user_name}用户不存在"